package cn.hxsteel.storage.module.tempturnover;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.hxsteel.model.vo.PageVO;
import cn.hxsteel.storage.core.base.BaseService;
import cn.hxsteel.storage.core.tool.DepotTool;
import cn.hxsteel.storage.model.dao.DepotDAO;
import cn.hxsteel.storage.model.dao.SheetDAO;
import cn.hxsteel.storage.model.dao.SheetDetailDAO;
import cn.hxsteel.storage.model.po.DepotPO;
import cn.hxsteel.storage.module.tempturnover.model.SheetVO;

@Service
class TempturnoverService extends BaseService
{
    @Autowired
    private SheetDAO        sheetDAO;
    @Autowired
    private SheetDetailDAO  sheetDetailDAO;
    @Autowired
    private DepotDAO        depotDAO;
    private List< SheetVO > bill;
    
    /**
     * 返回包含有出库明细的出库单列表
     * 
     * @param pageNo 当前页码
     * @param pageSize 每页显示条数
     */
    public List< SheetVO > giveBillData( int pageNo, int pageSize, int kind )
    {
	PageVO< SheetVO > pageVO = sheetDAO.selSheetPage( pageNo, pageSize, kind );
	super.savePagerData( pageVO );
	bill = pageVO.getResult();
	return bill;
    }
    
    /**
     * 返回仓库列表集合
     */
    public String giveDepotList()
    {
	List< DepotPO > depotList = depotDAO.selDepotList();
	return DepotTool.giveDepotList( depotList ).toString();
    }
    
    /**
     * 更新出库单的审核状态并且将该单据所有库存明细的库位进行更新
     * 
     * @param depotUpdate
     * @throws ProcExecFailException
     */
    public void updateDepot( String[] ids )
    // throws ProcExecFailException
    {
	// int length = ids.length;
	// boolean isSuccess;
	// for ( int i = 0; i < length; i++ )
	// {
	// int id = Integer.parseInt( ids[i] );
	// isSuccess = sheetDAO.updStepKind( id, StepKindEnum.COMPLETE.ordinal() );
	// if ( !isSuccess ) { throw new ProcExecFailException( String.valueOf( id ) ); }
	//
	// for ( SheetVO vo : bill )
	// {
	// if ( vo.getId() == id && vo.getDepotID() != 0 )
	// {
//		    // @formatter:off
//		    /* isSuccess = sumDayDepotDAO.chgSumDayDepot( vo.getStepKind(), 0, vo.getDepotID(), vo.getGoodsID(), 
//			    vo.getCreateTime(), vo.getNumber(), vo.getWeight() );*/
//		    if ( !isSuccess ) { throw new ProcExecFailException( String.valueOf( id ) ); }
//		}
//	    }
//	}
    }
    
    /**
     * 更细库存明细
     * 
     * @param id
     * @param depotID
     * @param number
     * @param weight
     * @throws ProcExecFailException
     */
    public void updateSheetDetail( int id, int depotID, int number, double weight )
	    //throws ProcExecFailException
    {
//	boolean isSuccess = sheetDetailDAO.updSheetDetail( id, depotID, number, weight );
//	if ( !isSuccess ) { throw new ProcExecFailException( String.valueOf( id ) ); }
    }
}
